/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package processtimeline;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Set;
import java.util.TreeSet;

/**
 *
 * @author nafeez
 */
public class WindowsCommand implements CommandInterface {

    private static final String COMMAND_ALL_RUNNING_PROCESS = System.getenv("windir") + "\\system32\\" + "tasklist.exe";

    public TreeSet<String> getRunningProcessNames() {
        TreeSet<String> data = new TreeSet<String>();
        try {
            String line;
            Process p = Runtime.getRuntime().exec(COMMAND_ALL_RUNNING_PROCESS);
            BufferedReader input =
                    new BufferedReader(new InputStreamReader(p.getInputStream()));
            while ((line = input.readLine()) != null) {
                data.add(line.split(".exe")[0]);
            }
            input.close();
        } catch (Exception err) {
            err.printStackTrace();
        }

        return data;

    }
}
